<template>
	<view class="px-3">
		<input class="uni-input" type="text" v-model="oldpassword" placeholder="输入旧密码"/>
		<input class="uni-input" type="text" v-model="newpassword" placeholder="输入新密码"/>
		<input class="uni-input" type="text" v-model="renewpassword" placeholder="再次确认新密码"/>
		<view class="px-2 py-3">
			<button class="bg-main text-white" style="border-radius: 50rpx;" type="primary"
			:disabled="disabled" :class="disabled ? 'bg-main-disabled' : ''"
			@click="submit"
			>设置密码</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldpassword: '',
				newpassword: '',
				renewpassword: ''
			}
		},
		computed:{
			disabled() {
				return this.oldpassword == '' || this.newpassword == '' || this.renewpassword == ''
			}
		},
		methods:{
			check() {
				if (this.newpassword !== this.renewpassword) {
					uni.showToast({
						title:'新密码不一致，请重新输入',
						icon:'none'
					})
					return false
				}
				return true
			},
			submit() {
				if (!this.check()) {
					return
				}
				console.log('密码设置成功')
			}
		}
	}
</script>

<style>
</style>
